package com.dongdongshop.service;

import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemExample;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService
public class TbItemServiceImpl implements TbItemService {

    @Autowired
    private TbItemMapper tbItemMapper;

    @Override
    public List<TbItem> selectByGoodsId(Long goodsId) {
        TbItemExample tie = new TbItemExample();
        TbItemExample.Criteria criteria = tie.createCriteria();
        criteria.andGoodsIdEqualTo(goodsId);//属于某一个SPU
        criteria.andStockCountGreaterThan(0);//库存>0
        criteria.andStatusEqualTo("1");//正常的
        return tbItemMapper.selectByExample(tie);
    }
}
